package com.insight.dto.collection;

import com.insight.entity.MetadataColumn;
import com.insight.entity.MetadataIndex;
import com.insight.entity.MetadataTable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * 表详细信息DTO
 * 用于在Virtual Thread和主线程之间传递采集的元数据
 *
 * @author Insight Team
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TableDetails {

    /**
     * 表元数据
     */
    private MetadataTable table;

    /**
     * 列列表
     */
    private List<MetadataColumn> columns;

    /**
     * 索引列表
     */
    private List<MetadataIndex> indexes;

    /**
     * 是否成功
     */
    private boolean success;

    /**
     * 错误信息(如果失败)
     */
    private String errorMessage;

    /**
     * 创建成功的TableDetails
     */
    public static TableDetails success(MetadataTable table, List<MetadataColumn> columns, List<MetadataIndex> indexes) {
        TableDetails details = new TableDetails();
        details.setTable(table);
        details.setColumns(columns);
        details.setIndexes(indexes);
        details.setSuccess(true);
        return details;
    }

    /**
     * 创建失败的TableDetails
     */
    public static TableDetails failure(MetadataTable table, String errorMessage) {
        TableDetails details = new TableDetails();
        details.setTable(table);
        details.setSuccess(false);
        details.setErrorMessage(errorMessage);
        return details;
    }
}
